package PTA.练习0501;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-11-14
 * Time: 8:55
 */
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        GeometricObject triangle1 = new Triangle();
        double x = input.nextDouble();
        double y = input.nextDouble();
        double z = input.nextDouble();
        input.close();
        GeometricObject triangle2 = new Triangle(x, y, z);
        System.out.printf("The area of triangle 1 is : %.2f\n" , triangle1.getArea());
        System.out.printf("The area of triangle 2 is : %.2f\n", triangle2.getArea());
        System.out.printf("The perimeter of triangle 1 is : %.2f\n", triangle1.getPerimeter());
        System.out.printf("The perimeter of triangle 2 is : %.2f\n", triangle2.getPerimeter());
        System.out.println("The color of triangle 1 is : " + triangle1.getColor());
        System.out.println("The color of triangle 2 is : " + triangle2.getColor());
    }
}
abstract class GeometricObject {
    private String color = "white";
    private boolean filled;
    private java.util.Date dateCreated;

    /** Construct a default geometric object */
    public GeometricObject() {
        dateCreated = new java.util.Date();
    }

    /**
     * Construct a geometric object with the specified color and filled value
     */
    public GeometricObject(String color, boolean filled) {
        dateCreated = new java.util.Date();
        this.color = color;
        this.filled = filled;
    }

    /** Return color */
    public String getColor() {
        return color;
    }

    /** Set a new color */
    public void setColor(String color) {
        this.color = color;
    }

    /**
     * Return filled. Since filled is boolean, its get method is named isFilled
     */
    public boolean isFilled() {
        return filled;
    }

    /** Set a new filled */
    public void setFilled(boolean filled) {
        this.filled = filled;
    }

    /** Get dateCreated */
    public java.util.Date getDateCreated() {
        return dateCreated;
    }

    /** Return a string representation of this object */
    public String toString() {
        return "created on " + dateCreated + "\ncolor: " + color + " and filled: " + filled;
    }

    /** Return the area of this object */
    public abstract double getArea();

    /** Return the perimeter of this object */
    public abstract double getPerimeter();

}

class Triangle extends GeometricObject{
    double side1;
    double side2;
    double side3;
    Triangle(double x,double y,double z){
        this.side1=x;
        this.side2=y;
        this.side3=z;
    }
    Triangle(){
        this.side1=1;
        this.side2=1;
        this.side3=1;
    }

    @Override
    public double getArea() {
        double p=(side1+side2+side3)/2;
        return Math.sqrt(p*((p-side1)*(p-side2)*(p-side3)));
    }

    @Override
    public double getPerimeter() {
        return side1+side2+side3;
    }
}
